package com.yeyks;

import com.alibaba.fastjson.JSON;
import com.google.common.collect.Lists;
import com.yeyks.common.appcommon.dto.order.AppGrabOrderDTO;
import com.yeyks.common.utils.DateUtils;
import com.yeyks.hotel.dal.domain.HotelBlackList;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;
import java.util.List;
import java.util.Random;
import java.util.Scanner;

/**
 * @author: dagny
 * @date: 2019/7/2 0002 15:59
 */
@Slf4j
public class test {
    public static void main(String[] args) {
        System.out.println(DateUtils.dateToyyyyMMdd(new Date()));

        System.out.println(DateUtils.getDateForDay(30));

        String address = "江西省.南昌市.其它区";
        System.out.println(address.split("\\.")[address.split("\\.").length-1]);
        boolean status = false;
        System.out.println(status ? 1 : 0);


        System.out.println("你好" + "\n\t" + "嘿嘿");

        String hotelName = "“测试酒店名称-4351”入驻了夜鱼平台.";

        System.out.println(hotelName.substring(1,hotelName.indexOf("”")));

        System.out.println((System.currentTimeMillis()-DateUtils.ymdhmsToDate("2019-12-09 16:58:24").getTime())/1000);


        List<AppGrabOrderDTO> grabOrderDTOList = Lists.newArrayList();
        AppGrabOrderDTO appGrabOrderDTO = new AppGrabOrderDTO();
        appGrabOrderDTO.setStartTime(new Date());
        appGrabOrderDTO.setPhone("1");

        System.out.println("今天"+DateUtils.toYYMMddStr(new Date()) +"明天的时间" + DateUtils.toYYMMddStr(DateUtils.dayAfter(new Date(),1)));


        System.out.println(System.currentTimeMillis());

        long longtimestamp = LocalDate.now().atStartOfDay(ZoneOffset.ofHours(8)).toInstant().toEpochMilli();
        long longNowTimestamp = LocalDateTime.now().toInstant(ZoneOffset.ofHours(8)).toEpochMilli();
        System.out.println(longtimestamp);
        System.out.println(longNowTimestamp);

        String st = "1";

        System.out.println(st + 1);

        /*AppGrabOrderDTO appGrabOrderDTO1 = new AppGrabOrderDTO();
        appGrabOrderDTO1.setStartTime(DateUtils.toDateTime("2019-09-19 16:58:24"));
        appGrabOrderDTO1.setPhone("2");
        grabOrderDTOList.add(appGrabOrderDTO);
        grabOrderDTOList.add(appGrabOrderDTO1);

        grabOrderDTOList = grabOrderDTOList.stream().sorted(Comparator.comparing(AppGrabOrderDTO::getStartTime).reversed()).collect(Collectors.toList());*/

        System.out.println("数据" + JSON.toJSONString(grabOrderDTOList));


        System.out.println((int)(Double.valueOf("123.3") * 0.95) * 100);

        System.out.println((int) ((Double.valueOf("123.3") / 100) * 100));

        System.out.println((Double.valueOf("123.3").intValue()));

        Random random = new Random();
        int index = random.nextInt(1);

        System.out.println("随机数" + index);

        HotelBlackList hotelBlackList = new HotelBlackList();
        if(null == hotelBlackList){
            System.out.println("你不是空对象");
        }

    }

//    @Test
//    public void testCallBack(){
//        CbDataSync cbDataSync = new CbDataSync();
//        cbDataSync.setSyncType(String.valueOf(SyncTypeConst.HOTEL));
//        CbData data = new CbData();
//        CbHotelData hotelData = new CbHotelData();
//        hotelData.setHotelId("82205");
//        hotelData.setHotelStatus("015004");
//        data.setHotel(hotelData);
//        cbDataSync.setData(data);
//        //转换成xml
//        String requestParam = XML.toXml(JSONUtil.parseObj(cbDataSync), "DataSync");
//        //加密request
//        requestParam = AesEncoderUtil.getInstance().encrypt(requestParam);
//
//        log.info(requestParam);
//
//        HttpUtil.createPost("http://192.168.5.8:8088/cb/return/callback?xmlRequest="+requestParam);
//    }

    @Test
    public void testDate(){

        Long dates = System.currentTimeMillis();
        System.out.println(dates);
        String date = DateUtils.stampToYMDStr(dates);
        log.info("最终时间为:{}",date);
        System.out.println(date);

    }

    @Test
    public void testNum(){

//        Scanner sc = new Scanner(System.in);
//        String next = sc.next();
//        System.out.println(next);
    }
}
